﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SharedLibraries
{
    public class Tools
    {


        //public static Int32 Count_Character(String strInput)
        //{
        //    return strInput.Length;
        //}

        //public static Int32 Count_Word(String strInput)
        //{
        //    lblResult.Text = StringEx.TrimEx(txtInput.Text).Split(' ').Length.ToString();
        //}

        //protected void Upper_Case(String strInput)
        //{
        //    txtOutput.Text = txtInput.Text.ToUpper();
        //}

        //protected void Lower_Case(String strInput)
        //{
        //    txtOutput.Text = txtInput.Text.ToLower();
        //}

        //protected void Upper_Firt_Char(String strInput)
        //{
        //    txtOutput.Text = Commons.UppercaseFirst(txtInput.Text);
        //}

        //protected void Reverse(String strInput)
        //{
        //    txtOutput.Text = Commons.Reverse(txtInput.Text);
        //}

        //protected void MD5_Encode(String strInput)
        //{
        //    txtOutput.Text = Security.MD5_Encrypt(txtInput.Text);
        //}

        //protected void SHA1_Encode()
        //{
        //    txtOutput.Text = Security.SHA1_Encrypt(txtInput.Text);
        //}

        //protected void Url_Encode()
        //{
        //    txtOutput.Text = Server.UrlEncode(txtInput.Text);
        //}

        //protected void Url_Decode()
        //{
        //    txtOutput.Text = Server.UrlDecode(txtInput.Text);
        //}

        //protected void Html_Encode()
        //{
        //    txtOutput.Text = Server.HtmlEncode(txtInput.Text);
        //}

        //protected void Html_Decode()
        //{
        //    txtOutput.Text = Server.HtmlDecode(txtInput.Text);
        //}

        //protected void Generator_Password()
        //{
        //    lblResult.Text = Security.RandomPassword();
        //}

        //protected void Generator_Number()
        //{
        //    if (Convert.ToInt32(txtEnd.Text) < Convert.ToInt32(txtBegin.Text))
        //    {
        //        txtBegin.Focus();
        //        txtInput.Attributes["onfocus"] = "javascript:this.select();";
        //        return;
        //    }
        //    lblResult.Text = Commons.Random_Number(Convert.ToInt32(txtBegin.Text), Convert.ToInt32(txtEnd.Text)).ToString();
        //}

        //protected void QRCode()
        //{
        //    imgOutput.Visible = false;
        //    FSE.SOFT.QRCode.Codec.QRCodeEncoder qrCodeEncoder = new FSE.SOFT.QRCode.Codec.QRCodeEncoder();
        //    qrCodeEncoder.QRCodeEncodeMode = FSE.SOFT.QRCode.Codec.QRCodeEncoder.ENCODE_MODE.BYTE;
        //    qrCodeEncoder.QRCodeVersion = 5;
        //    qrCodeEncoder.QRCodeScale = 5;
        //    qrCodeEncoder.QRCodeErrorCorrect = 0;
        //    var bmpImage = qrCodeEncoder.Encode(txtInput.Text);
        //    System.IO.MemoryStream stream = new System.IO.MemoryStream();
        //    bmpImage.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
        //    byte[] imageBytes = stream.ToArray();
        //    imgOutput.ImageUrl = @"data:image/gif;base64," + Convert.ToBase64String(imageBytes);
        //    imgOutput.Visible = true;
        //}

        //protected void BarCode()
        //{
        //    imgOutput.Visible = false;
        //    if (txtInput.Text.Length > 18)
        //    {
        //        txtInput.Focus();
        //        txtInput.Attributes["onfocus"] = "javascript:this.select();";
        //        return;
        //    }
        //    FSE.SOFT.QRCode.Codec.BarCode.Barcode barcode = new FSE.SOFT.QRCode.Codec.BarCode.Barcode();
        //    barcode.Alignment = FSE.SOFT.QRCode.Codec.BarCode.AlignmentPositions.CENTER;
        //    barcode.LabelPosition = FSE.SOFT.QRCode.Codec.BarCode.LabelPositions.BOTTOMCENTER;
        //    barcode.IncludeLabel = false;
        //    var type = FSE.SOFT.QRCode.Codec.BarCode.TYPE.CODE128;
        //    Int32 W = 150;
        //    Int32 H = 50;
        //    var img = new Bitmap(barcode.Encode(type, txtInput.Text, System.Drawing.Color.Black, System.Drawing.Color.White, W, H));
        //    byte[] imageBytes = FSE.SOFT.QRCode.Codec.Util.QRCodeUtility.convertBitmapToByte(img);
        //    imgOutput.ImageUrl = @"data:image/gif;base64," + Convert.ToBase64String(imageBytes);
        //    imgOutput.Visible = true;
        //}

        //protected void Image_Watermark()
        //{
        //    if (String.IsNullOrEmpty(fuImage.PostedFile.FileName))
        //    {
        //        fuImage.Focus();
        //        return;
        //    }
        //    if (String.IsNullOrEmpty(txtText.Text))
        //    {
        //        txtText.Focus();
        //        return;
        //    }
        //    //Get the file name.
        //    string fileName = Path.GetFileNameWithoutExtension(fuImage.PostedFile.FileName) + "_watermark.png";

        //    //Read the File into a Bitmap.
        //    using (Bitmap bmp = new Bitmap(fuImage.PostedFile.InputStream, false))
        //    {
        //        using (Graphics grp = Graphics.FromImage(bmp))
        //        {
        //            //Set the Color of the Watermark text.
        //            Brush brush = new SolidBrush(System.Drawing.ColorTranslator.FromHtml(txtColor.Text));

        //            //Set the Font and its size.
        //            Font font = new System.Drawing.Font(ddlFont.SelectedValue, Convert.ToInt32(txtFontSize.Text), FontStyle.Bold, GraphicsUnit.Pixel);

        //            //Determine the size of the Watermark text.
        //            SizeF textSize = new SizeF();
        //            textSize = grp.MeasureString(txtText.Text, font);

        //            //Position the text and draw it on the image.
        //            Point position = new Point((bmp.Width - ((int)textSize.Width + 10)), (bmp.Height - ((int)textSize.Height + 10)));
        //            grp.DrawString(txtText.Text, font, brush, position);

        //            using (MemoryStream memoryStream = new MemoryStream())
        //            {
        //                //Save the Watermarked image to the MemoryStream.
        //                bmp.Save(memoryStream, ImageFormat.Png);
        //                memoryStream.Position = 0;

        //                //Start file download.
        //                Response.Clear();
        //                Response.ContentType = "image/png";
        //                Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);

        //                //Write the MemoryStream to the Response.
        //                memoryStream.WriteTo(Response.OutputStream);
        //                Response.Flush();
        //                Response.Close();
        //                Response.End();
        //            }
        //        }
        //    }
        //}

        //protected void String_Hex()
        //{
        //    txtOutput.Text = Commons.StringToHex(txtInput.Text);
        //}

        //protected void Hex_String()
        //{
        //    txtOutput.Text = Commons.HexToString(txtInput.Text);
        //}

        //protected void String_Binary()
        //{
        //    //txtOutput.Text = CommonLibrary.ConvertExt.StringToStringBit(txtInput.Text);
        //}

        //protected void Binary_String()
        //{
        //    throw new NotImplementedException();
        //}

        //protected void String_Base64()
        //{
        //    throw new NotImplementedException();
        //}

        //protected void Base64_String()
        //{
        //    throw new NotImplementedException();
        //}

        //protected void Decimal_Binary()
        //{
        //    throw new NotImplementedException();
        //}

        //protected void Binary_Decimal()
        //{
        //    throw new NotImplementedException();
        //}

        //protected void Decimal_Hex()
        //{
        //    throw new NotImplementedException();
        //}

        //protected void Hex_Decimal()
        //{
        //    throw new NotImplementedException();
        //}

        //protected void Color_Hex()
        //{
        //    throw new NotImplementedException();
        //}

        //protected void Color_RBG()
        //{
        //    throw new NotImplementedException();
        //}

        //protected void Color_Name()
        //{
        //    throw new NotImplementedException();
        //}
    }
}